#include <stdio.h>

typedef struct
{
    int index;
    int length;
    char *input;
} Data;

int main(int argc, char const *argv[])
{
    int m, i, l, j;
    char input[32][128], *p;
    Data datas[32], max;
    scanf("%d", &m);

    for (i = 0; i < m; i++)
    {
        scanf("%s", &input[i]);
    }
    
    for (i = 0; i < m; i++)
    {
        p = input[i];
        l = 0;
        while (*p)
        {
            l++;
            p++;
        }
        datas[i].length = l;
        datas[i].input = input[i];
        datas[i].index = i + 1;
    }

    max.index = -1;
    max.length = 0;

    for (i = 0; i < m; i++)
    {
        if (datas[i].length > max.length)
        {
            max.index = datas[i].index;
            max.length = datas[i].length;
            max.input = datas[i].input;
        }
        else if (datas[i].length == max.length)
        {
            for (j = 0; j < datas[i].length; j++)
            {
                if (datas[i].input[j] != max.input[j])
                {      
                    break;
                }
            }

            if (datas[i].input[j] > max.input[j])
            {
                max.index = datas[i].index;
                max.length = datas[i].length;
                max.input = datas[i].input;
            }
        }
    }
    
    printf("%d\n%s", max.index, max.input);

    return 0;
}
